package com.santiao.publics.ad.ads;


import android.app.Activity;
import android.content.Context;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;

import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.CSJAdError;
import com.bytedance.sdk.openadsdk.CSJSplashAd;
import com.bytedance.sdk.openadsdk.CSJSplashCloseType;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.mediation.MediationConstant;
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot;
import com.bytedance.sdk.openadsdk.mediation.ad.MediationSplashRequestInfo;
import com.bytedance.sdk.openadsdk.mediation.manager.MediationSplashManager;

import com.santiao.youxiang.MainActivity;
import com.santiao.youxiang.R;
import com.santiao.publics.config.Const;
import com.santiao.publics.util.SharedPreferencesUtil;
import com.santiao.publics.util.UIUtils;
import com.santiao.youxiang.SplashActivity;
import com.santiao.publics.util.LogUtil;
import com.umeng.umcrash.UMCrash;


/**
 * 开屏广告服务
 */
public class MediationSplashService {


    public String splashMediaId1;

    public String csjSplash1;
    private FrameLayout mSplashContainer1;
    private CSJSplashAd mCsjSplashAd1;
    private TTAdNative.CSJSplashAdListener mCSJSplashAdListener1;
    private CSJSplashAd.SplashAdListener mCSJSplashInteractionListener1;
    public  String ecpm1 = "";
    public  String slotId1 = "";

    public   MediationSplashManager manager1;

    public  boolean onSplashLoadSuccess1 =false;
    //插屏是否显示成功
    public static  boolean onSplashAdShow1=false;

    //素材加载状态
    public static boolean onSplashRenderSuccess1 = false;

    //是否加载异常
    public boolean onLoadErr1 = false;
    public static  boolean onSplashAdClose1 = false;
    //是否完成显示
    public static boolean doubleShowOK1 = false;

    public  View splashView1;
    //插屏是否显示成功

    public static  boolean onSplashAdShow2=false;

    public  boolean onSplashLoadSuccess2 =false;
    public   MediationSplashManager manager2;
    private TTAdNative.CSJSplashAdListener mCSJSplashAdListener2;
    private CSJSplashAd mCsjSplashAd2;
    private FrameLayout mSplashContainer2;
    public String splashMediaId2;

    public String csjSplash2;
    private CSJSplashAd.SplashAdListener mCSJSplashInteractionListener2;


    //素材加载状态
    public static boolean onSplashRenderSuccess2 = false;

    //是否加载异常
    public boolean onLoadErr2 = false;
    public static boolean onSplashAdClose2 = false;

    //是否完成显示
    public static boolean doubleShowOK2 = false;

    public  View splashView2;
    public  String ecpm2 = "";
    public  String slotId2 = "";

    public  Context context ;
    public  Activity activity ;
    public  String adStyle="4";

    public String errType1 = "";

    public String classNames = "";

    /**
     *
     * @param contexts
     * @param activitys
     * @param mSplashContainers1  控件1
     * @param splashMediaIds1   广告位1
     * @param csjSplashs1    兜底1
     * @param mSplashContainers2 控件2
     * @param splashMediaIds2 广告位2
     * @param csjSplashs2 兜底2
     */
    public void intiDate(Context contexts, Activity activitys, FrameLayout mSplashContainers1, String splashMediaIds1,String csjSplashs1, FrameLayout mSplashContainers2, String splashMediaIds2,String csjSplashs2) {
            classNames = getClass().getSimpleName();
            Log.i(Const.TAG,   classNames+"___1____intiDate---------------success");

               this.activity = activitys;
            this.context = contexts;
                 this.onSplashAdShow1 = false;
                 this.onSplashAdClose1 = false;
                 this.doubleShowOK1 = false;
                 this.onSplashRenderSuccess1 = false;
                 this.onLoadErr1 = false;
                this.csjSplash1 = csjSplashs1;
                this.splashMediaId1 = splashMediaIds1;
                this.mSplashContainer1 = mSplashContainers1;



                this.onSplashAdShow2 = false;
                this.onSplashAdClose2 = false;
                this.doubleShowOK2 = false;
                this.onSplashRenderSuccess2 = false;
                this.onLoadErr2 = false;
                this.csjSplash2 = csjSplashs2;
                this.mSplashContainer2 = mSplashContainers2;
                this.splashMediaId2 = splashMediaIds2;
                loadFeedAd1();


                if(!SharedPreferencesUtil.getStatus(SharedPreferencesUtil.IF_AD_2)) {//非自然流量广告模式
                    loadFeedAd2();
                }

    }

    public  void loadFeedAd1(){
        //第一步、创建开屏自定义兜底对象
////             创建开屏自定义兜底对象，例如穿山甲如下
        MediationSplashRequestInfo csjSplashRequestInfo = new MediationSplashRequestInfo(
                MediationConstant.ADN_PANGLE, // 穿山甲
                csjSplash1, // adn开屏广告代码位Id，注意不是聚合广告位Id
                context.getString(R.string.gm_ad_id),   // adn应用id，注意要跟初始化传入的保持一致
//                        Const.APP_KEY   // adn没有appKey时，传入空即可
                null
        ) {};

        try {

            /** 1、创建AdSlot对象 */
            AdSlot adSlot = new AdSlot.Builder()
                    .setCodeId(splashMediaId1)
                    .setImageAcceptedSize(UIUtils.getScreenWidthInPx(context),UIUtils.getScreenHeightInPx(context))
                    .setMediationAdSlot(
                            new MediationAdSlot.Builder()
                                    //将自定义兜底对象设置给AdSlot
                                    .setMediationSplashRequestInfo(csjSplashRequestInfo)
                                    .build())
                    .build();
            Log.i(Const.TAG,   classNames+"___1____AdSlot---------------success");
            /** 2、创建TTAdNative对象 */
            TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(context);
            Log.i(Const.TAG,   classNames+"___1____adNativeLoader---------------success");
            /** 3、创建加载、展示监听器 */
            initListeners1();
            Log.i(Const.TAG,   classNames+"___1____initListeners---------------success");
            /** 4、加载广告 */
            adNativeLoader.loadSplashAd(adSlot, mCSJSplashAdListener1, Const.splashAdtime);
            Log.i(Const.TAG,  classNames+"___1____loadSplashAd---------------success");
        }catch (Exception e){
            if(Const.IF_UM) {
                UMCrash.generateCustomLog(e, "MediationSplashManager");
            }
            e.printStackTrace();
            goActivity("1","7");
        }finally {
            //初始化接口数据
            AdRequestService adRequestService = new AdRequestService();
            adRequestService.initAdRequest("2",adStyle,ecpm1,splashMediaId1,slotId1,null);
            adRequestService.reportRequest();
        }
    }



    public  void loadFeedAd2(){
        //第一步、创建开屏自定义兜底对象
////             创建开屏自定义兜底对象，例如穿山甲如下
        MediationSplashRequestInfo csjSplashRequestInfo = new MediationSplashRequestInfo(
                MediationConstant.ADN_PANGLE, // 穿山甲
                csjSplash2, // adn开屏广告代码位Id，注意不是聚合广告位Id
                context.getString(R.string.gm_ad_id),   // adn应用id，注意要跟初始化传入的保持一致
//                        Const.APP_KEY   // adn没有appKey时，传入空即可
                null
        ) {};

        try {

            /** 1、创建AdSlot对象 */
            AdSlot adSlot = new AdSlot.Builder()
                    .setCodeId(splashMediaId2)
                    .setImageAcceptedSize(UIUtils.getScreenWidthInPx(context),UIUtils.getScreenHeightInPx(context))
                    .setMediationAdSlot(
                            new MediationAdSlot.Builder()
                                    //将自定义兜底对象设置给AdSlot
                                    .setMediationSplashRequestInfo(csjSplashRequestInfo)
                                    .build())
                    .build();
            Log.i(Const.TAG,   classNames+"___2____AdSlot---------------success");
            /** 2、创建TTAdNative对象 */
            TTAdNative adNativeLoader = TTAdSdk.getAdManager().createAdNative(context);
            Log.i(Const.TAG,   classNames+"___2____adNativeLoader---------------success");
            /** 3、创建加载、展示监听器 */
            initListeners2();
            Log.i(Const.TAG,   classNames+"___2____initListeners---------------success");
            /** 4、加载广告 */
            adNativeLoader.loadSplashAd(adSlot, mCSJSplashAdListener2, Const.splashAdtime);
            Log.i(Const.TAG,  classNames+"___2____loadSplashAd---------------success");
        }catch (Exception e){
            if(Const.IF_UM) {
                UMCrash.generateCustomLog(e, "MediationSplashManager");
            }
            e.printStackTrace();
            goActivity("2","7");
        }finally {
            //初始化接口数据
            AdRequestService adRequestService = new AdRequestService();
            adRequestService.initAdRequest("2",adStyle,ecpm2,splashMediaId2,slotId2,null);
            adRequestService.reportRequest();
        }
    }



    private void initListeners1() {
        // 广告加载监听器
        this.mCSJSplashAdListener1 = new TTAdNative.CSJSplashAdListener() {
            @Override
            public void onSplashRenderSuccess(CSJSplashAd csjSplashAd) {// 	 广告渲染成功
                onSplashRenderSuccess1 =true;

                /** 5、渲染成功后，展示广告 */
                Log.d(Const.TAG, classNames+"___1____splash render success--1--onSplashAdShow2:"+onSplashAdShow2+"----onSplashRenderSuccess2:"+onSplashRenderSuccess2);
                mCsjSplashAd1 = csjSplashAd;
                manager1 = mCsjSplashAd1.getMediationManager();
                csjSplashAd.setSplashAdListener(mCSJSplashInteractionListener1);

                UIUtils.removeFromParent(splashView1);
                Log.d(Const.TAG, classNames+"___1____splash render success--2--onSplashAdShow2:"+onSplashAdShow2+"----onSplashRenderSuccess2:"+onSplashRenderSuccess2);
                if(mSplashContainer1!=null) {
                            if(onSplashRenderSuccess2==false) {
                                splashView1 = csjSplashAd.getSplashView();
                                mSplashContainer1.removeAllViews();
                                mSplashContainer1.addView(splashView1);
                                Log.d(Const.TAG, classNames+"___1____splash render success--ok--onSplashAdShow2:"+onSplashAdShow2+"----onSplashRenderSuccess2:"+onSplashRenderSuccess2);
                                showJob("1", "6");

                            }
                }
                Log.d(Const.TAG, classNames+"___1____splash render success--3--onSplashAdShow2:"+onSplashAdShow2+"----onSplashRenderSuccess2:"+onSplashRenderSuccess2);
            }

            @Override
            public void onSplashLoadSuccess(CSJSplashAd csjSplashAd) {//广告物料、素材加载成功
                onSplashLoadSuccess1 = true;
                Log.d(Const.TAG, classNames+"___1____splash load success");
            }

            @Override
            public void onSplashLoadFail(CSJAdError csjAdError) {//广告物料、素材加载失败或超时回调
                Log.d(Const.TAG, classNames+"___1____splash load fail, errCode: "+ SplashActivity.ifSplashActivity+"-------" + csjAdError.getCode() + ", errMsg: " + csjAdError.getMsg());


                if(SplashActivity.ifSplashActivity) {

                    goActivity("1","4");
                }
            }

            //广告渲染失败
            @Override
            public void onSplashRenderFail(CSJSplashAd csjSplashAd, CSJAdError csjAdError) {
                Log.d(Const.TAG, classNames+"___1____splash render fail, errCode:"+SplashActivity.ifSplashActivity+"-------" + csjAdError.getCode() + ", errMsg: " + csjAdError.getMsg());
                if(SplashActivity.ifSplashActivity) {

                    goActivity("1","5");
                }
            }
        };
        // 广告展示监听器
        this.mCSJSplashInteractionListener1 = new CSJSplashAd.SplashAdListener() {
            @Override
            public void onSplashAdShow(CSJSplashAd csjSplashAd) { //广告显示
                onSplashAdShow1 = true;
                Log.d(Const.TAG, classNames+"___1____splash show");
                if(manager1!=null){
                    ecpm1 = manager1.getShowEcpm().getEcpm();
                    slotId1 = manager1.getShowEcpm().getSlotId();
                }
                //初始化接口数据
                AdRequestService adRequestService = new AdRequestService();
                adRequestService.initAdRequest("0",adStyle,ecpm1, splashMediaId1,slotId1,null);
                adRequestService.reportRequest();
            }

            @Override
            public void onSplashAdClick(CSJSplashAd csjSplashAd) { //点击
                Log.d(Const.TAG, classNames+"___1____splash click");
                if(manager1!=null){
                    ecpm1 = manager1.getShowEcpm().getEcpm();
                    slotId1 = manager1.getShowEcpm().getSlotId();
                }
                //初始化接口数据
                AdRequestService adRequestService = new AdRequestService();
                adRequestService.initAdRequest("1",adStyle,ecpm1,splashMediaId1,slotId1,null);
                adRequestService.reportRequest();

            }

            @Override
            public void onSplashAdClose(CSJSplashAd csjSplashAd, int closeType) { //关闭
                onSplashAdClose1 = true;
                Log.d(Const.TAG, classNames+"____1___splash click Close-----ifSplashActivity:"+SplashActivity.ifSplashActivity);
                if (closeType == CSJSplashCloseType.CLICK_SKIP) {

                } else if (closeType == CSJSplashCloseType.COUNT_DOWN_OVER) {

                } else if (closeType == CSJSplashCloseType.CLICK_JUMP) {

                }
//                if(SplashActivity.ifSplashActivity) {

                    goActivity("1", "6");
//                }
            }
        };

}






    private void initListeners2() {
        // 广告加载监听器
        this.mCSJSplashAdListener2 = new TTAdNative.CSJSplashAdListener() {
            @Override
            public void onSplashRenderSuccess(CSJSplashAd csjSplashAd) {// 	 广告渲染成功

                onSplashRenderSuccess2 =true;
                /** 5、渲染成功后，展示广告 */
                Log.d(Const.TAG, classNames+"___2____splash render success--1--onSplashAdShow1:"+onSplashAdShow1+"----onSplashRenderSuccess1:"+onSplashRenderSuccess1);
                mCsjSplashAd2 = csjSplashAd;
                manager2 = mCsjSplashAd2.getMediationManager();
                csjSplashAd.setSplashAdListener(mCSJSplashInteractionListener2);
//
                UIUtils.removeFromParent(splashView2);
                Log.d(Const.TAG, classNames+"___2____splash render success--2--onSplashAdShow1:"+onSplashAdShow1+"----onSplashRenderSuccess1:"+onSplashRenderSuccess1);
                if(mSplashContainer2!=null) {
                    if(onSplashRenderSuccess1==false) {
                        splashView2 = csjSplashAd.getSplashView();
                        mSplashContainer2.removeAllViews();
                        mSplashContainer2.addView(splashView2);
                        Log.d(Const.TAG, classNames+"___2____splash render success--ok--onSplashAdShow1:"+onSplashAdShow1+"----onSplashRenderSuccess1:"+onSplashRenderSuccess1);
                        showJob ("2", "6");
                    }
                }
                Log.d(Const.TAG, classNames+"___2____splash render success--3--onSplashAdShow1:"+onSplashAdShow1+"----onSplashRenderSuccess1:"+onSplashRenderSuccess1);
            }

            @Override
            public void onSplashLoadSuccess(CSJSplashAd csjSplashAd) {//广告物料、素材加载成功
                onSplashLoadSuccess2 = true;
                Log.d(Const.TAG, classNames+"___2____splash load success");
            }

            @Override
            public void onSplashLoadFail(CSJAdError csjAdError) {//广告物料、素材加载失败或超时回调
                Log.d(Const.TAG, classNames+"___2____splash load fail, errCode: "+SplashActivity.ifSplashActivity+"-------" + csjAdError.getCode() + ", errMsg: " + csjAdError.getMsg());


                if(SplashActivity.ifSplashActivity) {

                    goActivity("2", "4");
                }
            }

            //广告渲染失败
            @Override
            public void onSplashRenderFail(CSJSplashAd csjSplashAd, CSJAdError csjAdError) {
                Log.d(Const.TAG, classNames+"___2____splash render fail, errCode:"+SplashActivity.ifSplashActivity+"-------" + csjAdError.getCode() + ", errMsg: " + csjAdError.getMsg());
                if(SplashActivity.ifSplashActivity) {

                    goActivity("2", "5");
                }
            }
        };
        // 广告展示监听器
        this.mCSJSplashInteractionListener2 = new CSJSplashAd.SplashAdListener() {
            @Override
            public void onSplashAdShow(CSJSplashAd csjSplashAd) { //广告显示
                onSplashAdShow2 = true;
                Log.d(Const.TAG, classNames+"___2____splash show");
                if(manager2!=null){
                    ecpm2 = manager2.getShowEcpm().getEcpm();
                    slotId2 = manager2.getShowEcpm().getSlotId();
                }
                //初始化接口数据
                AdRequestService adRequestService = new AdRequestService();
                adRequestService.initAdRequest("0",adStyle,ecpm2, splashMediaId2,slotId2,null);
                adRequestService.reportRequest();
            }

            @Override
            public void onSplashAdClick(CSJSplashAd csjSplashAd) { //点击
                Log.d(Const.TAG, classNames+"___2____splash click");
                if(manager2!=null){
                    ecpm2 = manager2.getShowEcpm().getEcpm();
                    slotId2 = manager2.getShowEcpm().getSlotId();
                }
                //初始化接口数据
                AdRequestService adRequestService = new AdRequestService();
                adRequestService.initAdRequest("1",adStyle,ecpm2,splashMediaId2,slotId2,null);
                adRequestService.reportRequest();

            }

            @Override
            public void onSplashAdClose(CSJSplashAd csjSplashAd, int closeType) { //关闭

                onSplashAdClose2 = true;
                Log.d(Const.TAG, classNames+"____2___splash click Close-----ifSplashActivity:"+SplashActivity.ifSplashActivity);
                if (closeType == CSJSplashCloseType.CLICK_SKIP) {

                } else if (closeType == CSJSplashCloseType.COUNT_DOWN_OVER) {

                } else if (closeType == CSJSplashCloseType.CLICK_JUMP) {

                }
//                if(SplashActivity.ifSplashActivity) {

                    goActivity("2", "6");
//                }
            }
        };

    }




    /**
     *  adType :1  插屏  2 插屏2
     *  type:  4 素材加载失败或超时回调 5广告渲染失败 6 关闭  7:加载广告异常
     *
     * @param adType
     * @param type
     */
    public void goActivity(String adType, String type ){
                     boolean  ifgoActivity = false;

                     if(!"6".equals(type)) {
                         if ("1".equals(adType)) {
//                             if ("7".equals(type)) {
//                                 onSplashRenderSuccess1 = true;
//                             } else {
                                 onLoadErr1 = true;
//                             }
                         } else if ("2".equals(adType)) {
//                             if ("7".equals(type)) {
//                                 onSplashRenderSuccess2 = true;
//                             } else {
                                 onLoadErr2 = true;
//                             }
                         }

                     }else{//关闭开屏(type 6)
                         /**
                          * 1 另外一个加载成功继续显示
                          */

//                         try {

                         if("1".equals(adType)){
                              if(onSplashAdShow2 == false ){
                                  Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------1");
                                 if(onSplashRenderSuccess2) {
                                     Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------2");
                                     if(mCsjSplashAd2!=null){//插屏2加载成功 且没显示过

                                               Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------3");
                                               if (mSplashContainer2 != null) {
                                                  splashView2 = mCsjSplashAd2.getSplashView();

                                                   UIUtils.removeFromParent(splashView2);


                                                   if(mSplashContainer1!=null){
//                                                       mSplashContainer1.setVisibility(View.GONE);
//                                                       mSplashContainer1.removeAllViews();
                                                   }
//                                                   mSplashContainer2.setVisibility(View.VISIBLE);
                                                   Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------4");
                                                   mSplashContainer2.removeAllViews();
                                                   mSplashContainer2.addView(splashView2);


                                                   doubleShowOK2 = true;
                                                   timeJob();
                                                   return;

                                               }

                                      }
                                  }
                                  Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------5");
                                  if(SplashActivity.ifSplashActivity) {
                                      Log.i(Const.TAG, classNames+"---MainActivity--666666666");
                                      MainActivity.gotoActivity(context);
                                      activity.finish();
                                      return;
                                  }
                              }
                         }else   {
                             if(onSplashAdShow1 == false ){
                                 Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------1");
                                 if(onSplashRenderSuccess1){
                                     Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------2");

                                       if(mCsjSplashAd1!=null) {////插屏1加载成功且没显示过
                                           Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------3");
                                      if (mSplashContainer1 != null) {

                                          splashView1=mCsjSplashAd1.getSplashView();
                                          UIUtils.removeFromParent(splashView1);
                                          UIUtils.removeFromParent(splashView2);
                                          if(mSplashContainer2!=null){

//                                              mSplashContainer2.setVisibility(View.GONE);
//                                              mSplashContainer2.removeAllViews();
                                          }
//                                          mSplashContainer1.setVisibility(View.VISIBLE);
                                          Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------4");
                                          mSplashContainer1.removeAllViews();
                                          mSplashContainer1.addView(splashView1);
                                          doubleShowOK1 = true;
                                          timeJob();
                                          return;

                                      }


                                    }
                                  }
                                 Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------5");
                                 if(SplashActivity.ifSplashActivity) {
                                     Log.i(Const.TAG, classNames+"---MainActivity--777777777");
                                     MainActivity.gotoActivity(context);
                                     activity.finish();
                                     return;
                                 }

                             }
                         }

//                         }catch ( Exception e){
//                             e.printStackTrace();
//                         }

                     }



                 Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------onLoadErr1:"+onLoadErr1+"----onLoadErr2:"+onLoadErr2+"---onSplashAdShow1:"+onSplashAdShow1+"------onSplashAdShow2:"+onSplashAdShow2+"----onSplashAdClose1："+onSplashAdClose1+"-----onSplashAdClose2："+onSplashAdClose2+"---onSplashRenderSuccess1:"+onSplashRenderSuccess1+"---onSplashRenderSuccess2:"+onSplashRenderSuccess2);
                     if((onLoadErr1==true && onLoadErr2==true) //俩个都异常 或者加载成功的都显示完毕
                         || (onSplashAdClose1 && onSplashAdClose2)//俩个都显示了
                         || (onSplashAdShow1 && onSplashAdClose1 && onLoadErr2==true)    //一个显示成功且完成观看，单个加载失败
                         || (onSplashAdShow2 && onSplashAdClose2 && onLoadErr1==true)    //一个显示成功且完成观看，单个加载失败


                     ){
                         ifgoActivity = true;
                     }


                     Log.i(Const.TAG, classNames + "___adType:" + adType + "---MainActivity:" + type+"------ifgoActivity:"+ifgoActivity);
                     if(ifgoActivity) {

                         if(SplashActivity.ifSplashActivity) {
                             Log.i(Const.TAG, classNames+"---MainActivity--8888888888");

                             MainActivity.gotoActivity(context);

                             activity.finish();
                         }
                     }
    }


    //3s没显示，判断另外一个是否正常显示
    public void  showJob(String adType, String type ){
        CountDownTimer timer = new CountDownTimer(3000, 200) {
            @Override
            public void onTick(long l) {
            }

            @Override
            public void onFinish() {

                boolean ifbo= false;
                if("1".equals(adType)){ //开屏1  2s后没显示
                    if(onSplashAdShow1==false){
                        ifbo =true;
                    }
                }else{
                    if(onSplashAdShow2==false){ //开屏2  2s后没显示
                        ifbo =true;
                    }
                }
                LogUtil.i("","MediationSplashService---showJob-----ifbo:"+ifbo+"-----adType:"+adType+"---type:"+type);
                if(ifbo) {//ifbo 显示另外一个
                    goActivity(adType, type);
                }

            }
        };
        timer.start();
    }

    //避免双插屏显示不成功不跳转 3S后自动跳转
    public void timeJob(){
        CountDownTimer   timer = new CountDownTimer(7000, 200) {


            @Override
            public void onTick(long l) {

            }

            @Override
            public void onFinish() {

                if(SplashActivity.ifSplashActivity) {
                    Log.i(Const.TAG, classNames+"---MainActivity--999999999---job");
                    MainActivity.gotoActivity(context);

                    activity.finish();
                }
            }
        };
        timer.start();

    }


}
